<?php
class SSO implements IFilter
{
    public function  doFilter($render)
    {
        include(ROOT . "/config.inc.php");
        if (!array_key_exists("credentials", $_SESSION) && array_key_exists($cookiepre . '_auth', $_COOKIE)) {
            $synCookie_auth = $_COOKIE[$cookiepre . '_auth'];
            $discuz_auth_key = md5(UC_KEY . $_SERVER['HTTP_USER_AGENT']);
            $auth = explode("\t", Util::_authcode($synCookie_auth, 'DECODE', $discuz_auth_key));
            $userName = $auth[0];
            include_once(ROOT . "/proxy/Modules.proxy.php");
            $proxy = new Modules();
            $user = $proxy->User;
            $user->setUserName($userName);
            $user->cookieLogin();
        }
        if (array_key_exists("credentials", $_SESSION) &&array_key_exists("userType",$_SESSION) && $_SESSION['userType'] != 'admin') {
            if (array_key_exists("credentials", $_SESSION) && !array_key_exists($cookiepre . '_auth', $_COOKIE)) {
                $_SESSION = array();
            }
        }

    }
}

?>